<template>
  <div>
    <el-dialog title="会员列表" :visible.sync="dialogVisible" :before-close="handleClose" width="650px">
      <el-table :data="members.data">
        <el-table-column type="index" label="序号"/>
        <el-table-column prop="name" label="姓名"/>
        <el-table-column prop="phone" label="手机号"/>
        <el-table-column label="操作">
          <template slot-scope="item">
            <div class="select-doctor" @click="selectMember(item.row)">选择</div>
          </template>
        </el-table-column>
      </el-table>
      <div v-if="members.data.length > 0" class="pager">
        <el-pagination background
                       layout="sizes,prev,pager,next,jumper,->,slot"
                       @current-change="handlePageChange"
                       @next-click="handlePageChange"
                       @prev-click="handlePageChange"
                       :current-page="pageTerms.pageNo"
                       :page-size="pageTerms.pageSize"
                       :total="members.count">
        </el-pagination>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'membersDialog',
  data () {
    return {
      dialogVisible: false,
      pageTerms: {
        pageNo: 1,
        pageSize: 5
      }
    }
  },
  props: {
    members: {
      type: Object
    }
  },
  methods: {
    handlePageChange (val) {
      this.pageTerms.pageNo = val
      this.$emit('memberPages', this.pageTerms)
    },
    selectMember (doctor) {
      this.$emit('selectMember', doctor)
      this.dialogVisible = false
    },
    show () {
      this.dialogVisible = true
    },
    handleClose () {
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped lang="scss">
@import "~@/styles/variables";
.select-doctor{
  cursor: pointer;
  color: $mainBg;
}
.pager {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>
